//
//  CollectionView.m
//  AoJi
//
//  Created by IMacLife on 15/1/30.
//  Copyright (c) 2015年 xuanheng. All rights reserved.
//
//个人中心

#import "CollectionView.h"
#import "Color.h"
#import "CollectionDetailViewController.h"

@implementation CollectionView

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self loadView];
    }
    return self;
}

//加载view
-(void)loadView
{
    _tableview = [[UITableView alloc]initWithFrame:self.bounds style:UITableViewStylePlain];
    _tableview.delegate=self;
    _tableview.dataSource=self;
    _tableview.backgroundColor=[UIColor clearColor];
    [self addSubview:_tableview];
    
    imgArray = @[@"xuexiao",@"huodong",@"mianshi",@"luxian",@"kecherng"];
    array = @[@"学校详情",@"活动详情",@"面试详情",@"路线详情",@"课程详情"];
    
    UIView *footView = [[UIView alloc]init];
    footView.backgroundColor=[Color colorFromHexRGB:@"e4e4e4"];
    _tableview.tableFooterView=footView;
}

#pragma mark ----------------UITableViewDelegate
//一个分区显示多少行
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return array.count;
}


//UITableViewCell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"cell";
    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    cell.imageView.image = [UIImage imageNamed:imgArray[indexPath.row]];
    cell.textLabel.text=array[indexPath.row];
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    
    
    return cell;
}

//cell   -------   select
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    CollectionDetailViewController *detailVC = [[CollectionDetailViewController alloc] init];
    detailVC.flag = indexPath.row;
    [_viewController.navigationController pushViewController:detailVC animated:YES];
}

//cell行高
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 51;
}

@end
